package cn.blb.service.edu.controller;


import cn.blb.common.result.Result;
import cn.blb.service.edu.entity.vo.SubjectVo;
import cn.blb.service.edu.service.SubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author ccl
 * @since 2022-03-17
 */
@RestController
@RequestMapping("/edu/subject")
@CrossOrigin
@Api(tags = "课程分类列表")
public class SubjectController {

    private final SubjectService subjectService;

    public SubjectController(SubjectService subjectService) {
        this.subjectService = subjectService;
    }

    @GetMapping("nested-list")
    @ApiOperation(value = "获取所有课程")
    public Result nestedList() {
        List<SubjectVo> subjectVos = subjectService.nestedList();
        return Result.ok().setData("items", subjectVos);
    }

    @PostMapping ("import")
    public Result batchImport(MultipartFile file) {
        subjectService.batchImport(file);
        return Result.ok().setMessage("批量导入成功");
    }

}

